package ExerciseTwo;

public class Test1 {
	public static void main(String[] args) {
//		Son son1 = Son.getSon();
//		Son son2 = Son.getSon();
//		son1.setName("石文学");
//		son1.setAge(18);
//		son2.setName("普元庆");
//		son2.setAge(19);
//		System.out.println(son1);
//		System.out.println(son2);
		
		Sun sun1 = Sun.getSun();
		Sun sun2 = Sun.getSun();
		sun1.setAge(19);
		sun1.setName("好好");
		sun1.setAge(32);
		sun1.setName("看就看");
		System.out.println(sun1);
		System.out.println(sun2);
		
		
	}

}


class Son
{
	private String name;
	private int age;
	private static Son son = new Son();
	
	private Son()
	{
		
	}

	public static Son getSon()
	{
		return son;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public void eat()
	{
		System.out.println("吃饭");
	}

	@Override
	public String toString() {
		return "Son [name=" + name + ", age=" + age + "]";
	}
	
}

class Sun
{
	private String name;
	private int age;
	private static Sun sun = null;
	
	private Sun()
	{
		
	}
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public static Sun getSun()
	{
		if(sun == null)
		{
			synchronized (Sun.class) {
				if(sun == null)
				{
					sun = new Sun();
				}
			}
		}
		return sun;
	}
	public void sleep()
	{
		System.out.println("每天睡十二个小时");
	}
	@Override
	public String toString() {
		return "Sun [name=" + name + ", age=" + age + "]";
	}
	
}